package com.zx.rbac.ums.service.impl;

import com.zx.rbac.ums.dao.UmsMenuDao;
import com.zx.rbac.ums.model.UmsMenuEntity;
import com.zx.rbac.ums.model.UmsRoleEntity;
import com.zx.rbac.ums.service.UmsMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;


@Service("umsMenuService")
public class UmsMenuServiceImpl implements UmsMenuService {

    @Autowired
    private UmsMenuDao umsMenuDao;

    @Override
    public List<UmsMenuEntity> selectByRoles(List<UmsRoleEntity> roleEntities) {
        //将ID提取出来
        List<Long> roleIds = roleEntities.stream().map(UmsRoleEntity::getId).collect(Collectors.toList());
        return umsMenuDao.selectByRoles(roleIds);
    }
}
